import Vue from 'vue'
import router from './router'
import request from './utils/request'

import VueLazyLoad from 'vue-lazyload'
import VueCookie from 'vue-cookie'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import store from './store'
import App from './App.vue'
import imgUrl from '../env.js'

import * as custom from './utils/filters'
// 导出的是对象，可以直接通过 key 和 value 来获得过滤器的名和过滤器的方法
Object.keys(custom).forEach(key => {
  Vue.filter(key, custom[key])
})


Vue.use(ElementUI, {
  // size: 'small'
})
/**
 * 第二种方式：模拟接口数据
 * 常量mock为开关，需要自己写src/mock/api.js文件，即为下面require引入的代码
 */

const mock = false
if (mock) {
  // require('./mock/api')
}

Vue.use(VueCookie)
Vue.use(VueLazyLoad, {
  loading: '/imgs/loading-svg/loading-bars.svg'
})
Vue.prototype.$http = request
Vue.prototype.$img = imgUrl.imgUrl
Vue.config.productionTip = false

new Vue({
  store,
  router,
  render: h => h(App)
}).$mount('#app')
